package com.allwees.bs.module.pms.vo;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.metadata.BaseRowModel;
import com.allwees.bs.module.pms.entity.Category;
import com.allwees.bs.module.pms.entity.Product;
import com.allwees.bs.module.pms.entity.Sku;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

@Data
@EqualsAndHashCode(callSuper=true)
@NoArgsConstructor
public class ExportGaSkuVo extends BaseRowModel {
	@ExcelProperty("id")
	private String id;

	@ExcelProperty("title")
	private String title;

	@ExcelProperty("description")
	private String description;

	@ExcelProperty("product_type")
	private String productType;

	@ExcelProperty("google_product_category")
	private String googleProductCategory;

	@ExcelProperty("link")
	private String link;

	@ExcelProperty("image_link")
	private String imageLink;

	@ExcelProperty("condition")
	private String condition;

	@ExcelProperty("availability")
	private String availability;

	@ExcelProperty("price")
	private String price;

	@ExcelProperty("brand")
	private String brand;

	@ExcelProperty("gender")
	private String gender;

	@ExcelProperty("age_group")
	private String ageGroup;

	@ExcelProperty("gtin")
	private String gtin;

	@ExcelProperty("mpn")
	private String mpn;

	@ExcelProperty("color")
	private String color;

	@ExcelProperty("size")
	private String size;

	@ExcelProperty("custom_label_0")
	private String customLabel;

	public ExportGaSkuVo(Category category, Product product, Sku sku) {
		id = sku.getUuid();
		title = product.getName();
		description = product.getDescription();
		productType = category.getName();
		link = "https://www.allwees.com/product/info/" + product.getUuid();
		imageLink = StringUtils.isBlank(sku.getPhotosStr()) ? product.getMainPhoto() : sku.getPhotosStr().split(",")[0];
		price = sku.getRetailPrice().toPlainString();
		color = sku.getColor();
		size = sku.getSize();
		customLabel = product.getTotalSales().toString();
	}
}
